package com.shike.palmrejection;

import android.content.Context;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Config {

    public static final String DAY_POINT = "day_point";
    public static final String NIGHT_POINT = "night_point";
    public static final String S_HM = "sHm";
    public static final String E_HM = "eHm";
    public static final String IS_FIRST = "isFirst";
    public static final String MILLISECOND = "mMillisecond";

    // 获取光照强度
    public static float point(Context context) {
        int nowTime = timesAsCustomBackInt(Calendar.getInstance().getTimeInMillis(), "HHmm");

        int startTime = Integer.parseInt(SharepreferenceUtils.getString(context, S_HM, "800").replace(":", ""));
        int endTime = Integer.parseInt(SharepreferenceUtils.getString(context, E_HM, "1800").replace(":", ""));
        if (nowTime >= startTime && nowTime <= endTime) {
            return Float.parseFloat(SharepreferenceUtils.getString(context, DAY_POINT, "50"));
        } else {
            return Float.parseFloat(SharepreferenceUtils.getString(context, NIGHT_POINT, "10"));
        }
    }


    public static int timesAsCustomBackInt(long time,String like){
        SimpleDateFormat sdr = new SimpleDateFormat(like);
        String times = sdr.format(new Date(time));
        return Integer.parseInt(times);
    }
}
